package com.own.business.system.dictionary.entity.vo;

import com.own.business.system.dictionary.entity.po.SystemDictionary;
import com.own.component.common.base.entity.vo.BaseVo;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
 * SystemDictionaryVo
 *
 * @author chenxueli
 * @date 2023-06-21 09:41:16
 */
@Schema(title = "系统数据字典" + ConstantBeanSuffix.VO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class SystemDictionaryVo extends BaseVo<SystemDictionary> {

    @Schema(title = "字典名称")
    private String name;

    @Schema(title = "唯一编号")
    private String code;

    @Schema(title = "图标")
    private String icon;

    @Schema(title = "顺序，默认数字越小约在前面")
    private Integer sortOrder;

    /**
     * 构造方法
     *
     * @param entity 原对象
     */
    public SystemDictionaryVo(@NonNull SystemDictionary entity) {
        super(entity);
        this.name = entity.getName();
        this.code = entity.getCode();
        this.icon = entity.getIcon();
        this.sortOrder = entity.getSortOrder();
    }

    /**
     * 转po对象
     *
     * @param entity 原
     * @return po对象
     */
    @Override
    public SystemDictionary toPo(SystemDictionary entity) {
        if (entity == null) {
            entity = new SystemDictionary();
        }
        entity.setName(this.name);
        entity.setCode(this.code);
        entity.setIcon(this.icon);
        entity.setSortOrder(this.sortOrder);
        return super.toPo(entity);
    }

}
